/*
 * YouRlayer - The best music player on Sony PSP
 * Copyright(C) 2009 Umin (umin90@gmail.com)
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
 * for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
#include "tag.h"

extern struct *list;
extern struct info;

void readLrcAndCover(FILE *file){
}
void readID3v1tag(FILE *file,int mode,int n){
    if(mode==1){
        unsiged g;
        fread(list[n]->title,30,1,file);
        fread(list[n]->artist,30,1,file);
        fread(list[n]->album,30,1,file);
        fseek(SEEK_END,file);
        g=fgetc(file);
        strcpy(list[n]->genre,Genre[g]);
    }else{
        unsiged flag;
        fseek(-38,SEEK_END,file);
        fread(info->year,4,1,file);
        fread(info->comment,28,1,file);
        flag=fgetc(file);
        info->trackNumber=fgetc(file);
        if(flag!=0){
            sprintf(info->comment,"%s%c%c",info->comment,info->flag,info->trackNumber);
            strcpy(info->trackNumber,"Unkonw");
        }
    }
}


void readID3v2_3tag(FILE *file,int mode,int n){
}


void readAPEtag(FILE *file,int mode,int n){
}


void readTags(char *file,int mode,int n){
    FILE *fp=fopen(file,"rb");
    char tagExist[3];
    
    fseek(-128,SEEK_END,fp);
    fread(tagExist,3,1,fp);
    if(!strcmp(tagExist,"TAG"))
        readID3v1(fp,mode);
        fseek(SEEK_SET,fp);
        fread(tagExist,3,1,fp);
    else if(!strcmp(tagExist,"ID3"))
        readID3v2_3(fp,mode);
    else if()
    
    else{
        /* all unknow */
        if(mode==1){
            strcpy(list[n]->title,"Unkown");
            strcpy(list[n]->artist,"Unkown");
            strcpy(list[n]->album,"Unkown");
            strcpy(list[n]->genre,"Unkown");
        }else{
            info->cover=NULL;
            strcpy(info->lrc,"");
        }
    }
    fclose(fp);
}


